package cn._51doit.flink.day02.sources;

import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * 1.readTextFile是多并行的Source
 * 2.可以读取本地文件系统的文件或HDFS中的文件
 * 3.该Source创建的DataStream是一个有效的数据流（数据处理完后，程序退出）
 */
public class FileSource1 {

    public static void main(String[] args) throws Exception {

        Configuration configuration = new Configuration();
        configuration.setInteger("rest.port", 8081);
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(configuration);
        DataStreamSource<String> lines = env.readTextFile("/Users/start/Desktop/words.txt");
        //readTextFile方法创建的DataStream的并行度
        System.out.println("readTextFile方法创建的DataStream的并行度: " +lines.getParallelism());
        lines.print();
        env.execute();

    }
}
